package com.zeedev.flyingsaucer.global;

import android.content.Context;
import com.google.inject.Provides;
import com.google.inject.ProvisionException;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import com.zeedev.flyingsaucer.beers.activities.umbrella.UmbrellaActivity;
import com.zeedev.flyingsaucer.data.wrappers.PreferenceCredentials;
import mobi.zeedev.flyingsaucer.common.CredentialsModule.impl.Credentials;
import mobi.zeedev.flyingsaucer.common.CredentialsModule.interfaces.ICredentials;
import mobi.zeedev.flyingsaucer.common.CredentialsModule.interfaces.IPreferenceCredentials;
import roboguice.config.AbstractAndroidModule;
import roboguice.inject.SharedPreferencesName;


//SCALA
//import mobi.zeedev.flyingsaucer.scala.delegates.AutoPreferenceCredentials;

//JAVA

/**
 * User: James
 * Date: 1/20/11
 * Time: 3:33 PM
 */
public class UfoClubModule extends AbstractAndroidModule {


    @Override
    protected void configure() {


        bindConstant().annotatedWith(SharedPreferencesName.class).to(UfoClubApp.UFO_CLUB_APP_PREFS_FEB_2011);


//        bind(ICredentials.class).annotatedWith(Names.named("autoPreferenceCredentials")).to(AutoPreferenceCredentials.class);
//        bind(IPreferenceCredentials.class).annotatedWith(Names.named("autoIPreferenceCredentials")).to(AutoPreferenceCredentials.class);


        bind(ICredentials.class).annotatedWith(Names.named("autoPreferenceCredentials")).to(Credentials.class).asEagerSingleton();
        bind(IPreferenceCredentials.class).annotatedWith(Names.named("autoIPreferenceCredentials")).to(PreferenceCredentials.class).asEagerSingleton();


    }

    @Provides
    @Named("lastMemberId")
    Integer providesLastMemberId(UfoClubApp app) {
        return app.getLastMember();

    }

    @Provides
    @Named("umbrellaActivity")
    UmbrellaActivity providesUmbrellaActivity(Context mContext) {
        if (mContext.getClass() == UmbrellaActivity.class) {
            return (UmbrellaActivity) mContext;
        } else {
            throw new ProvisionException("UmbrellaActivity must be parent context in order to inject the UmbrellaListeners.");
        }

    }

//    @Provides
//    ICredentials providesDefaultCredentials(IPreferenceCredentials credentialsProvider) {
//        return credentialsProvider.getCredentials();
//    }

//    @Provides
//    @Named("defaultCredentials")
//    ICredentials providesDefaultCredentials() {
//
//    }

/*    @Provides
    @Named("defaultWriteableCredentials")
    IPreferenceCredentials providesDefaultCredentials(IPreferenceCredentials credentialsProvider) {
        return credentialsProvider.getCredentials();
    }*/


}
